package com.yej.aiPolice.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebSettings
import android.webkit.WebView
import androidx.fragment.app.Fragment
import com.yej.aiPolice.R
import com.yej.aiPolice.util.MyWebViewClient
import org.jetbrains.anko.find

open class WebViewFragment(val webUrl:String ) : Fragment() {
    private var mWebView: WebView? = null
    private var webSettings: WebSettings? = null
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val reportView = View.inflate(activity, R.layout.fragment_report, null)
        mWebView = reportView.find<WebView>(R.id.wv_report_web)

        init()
        return reportView
    }

    private fun init() {
        webSettings = mWebView?.settings
        webSettings!!.javaScriptEnabled = true
        webSettings!!.useWideViewPort =   true
        webSettings!!.setLoadWithOverviewMode(true)
        mWebView!!.setWebViewClient(MyWebViewClient())
        mWebView!!.loadUrl(webUrl)
    }
}